<?php

namespace seecms\controller;

use seecms\lib\builder\control\InputControl;
use seecms\lib\builder\modal\Dialog;
use seecms\lib\builder\query\TextQuery;
use seecms\lib\builder\toolbar\PageToolbar;
use seecms\SeeLang;

class UserRule extends Resource
{
    protected $table_name = 'see_user_rule';

    protected $dictionary_name = 'rule';

    protected function pageTitle(): string
    {
        return __('rule.page_title');
    }

    public function leftToolbars(): array
    {
        return [
            'create',
            PageToolbar::init('resource_rule')->setUrl(auth_route('permission/resourceRule'))->setIcon('layui-icon layui-icon-link')->setDialog(Dialog::init('resource_rule')->areaMiddle()),
            'del'
        ];
    }

    public function query(): array
    {
        return [
            TextQuery::init('title')->setExpressLike(),
            TextQuery::init('url')->setExpressLike(),
        ];
    }

    public function columns(): array
    {
        return [
            'id',
            'title',
            'url',
            'description',
            'created_at'
        ];
    }

    public function controls(): array
    {
        return [
            InputControl::init('group')->setDescription(SeeLang::rule('group_tip')),
            InputControl::init('title')->setDescription(SeeLang::rule('title_tip')),
            InputControl::init('url')->setDescription(SeeLang::rule('url_tip')),
            'description.false',
        ];
    }
}